/**
 * Copyright (c) 2023 - present All rights reserved.
 * <p>
 * Reprinted has been protected by the copyright laws.
 */

package cn.myxl.smart.devkit.commit.configuration;

import cn.myxl.smart.devkit.commit.model.CommitType;
import com.intellij.openapi.ui.DialogWrapper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.awt.*;

/**
 * @author zhangyang
 * @date 2023-11-14 14:39
 */

public class CommitTypeEditorUI extends DialogWrapper {

	public CommitTypeEditorUI(String title, CommitType commitType) {
		super(true);
		setTitle(title);

		titleField.setText(commitType.getTitle());
		descriptionField.setText(commitType.getDescription());

		init();
	}

	public CommitTypeEditorUI(String title) {
		super(true);
		setTitle(title);

		titleField.setText("");
		descriptionField.setText("");

		init();
	}

	private JPanel CommitTypeEditorPanel;

	private JTextField titleField;

	private JTextField descriptionField;

	public String getTitle() {
		return titleField.getText().trim();
	}

	public String getDescription() {
		return descriptionField.getText().trim();
	}

	@Override
	protected @Nullable JComponent createCenterPanel() {
		return CommitTypeEditorPanel;
	}
}
